package com.xxgc.vfc.common.error.system;

import com.xxgc.vfc.api.result.Result;
import com.xxgc.vfc.common.error.ErrorMessage;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindException;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.ValidationException;
import java.util.List;
import java.util.stream.Collectors;

/*
 *
 *   @Author: Sjy
 *   @Date: 2023/11/8-11-08-14:45
 *
 */
@ControllerAdvice
@ResponseBody
public class SystemError {


    @ExceptionHandler(value = {IllegalArgumentException.class})
    public ResponseEntity<Result> illegalArgumentException(IllegalArgumentException e) {
        return new ResponseEntity<>(
                Result.error().data(
                        ErrorMessage.getErrorMessage("VFC-1108-SYSTEM-0001",e.getMessage()).levels(5)
                ),
                HttpStatus.INTERNAL_SERVER_ERROR
        );
    }




}
